<?php

namespace app\v1\model;

use think\Model;
use think\Db;

/**
 * Class Cook
 * @package app\v1\model
 * 模块说明：这是校园食谱模块
 */
class Cook extends Base
{
    //校园食谱
    public function getCookList(){
        $userInfo=getUserInfo();
        $schoolId=$userInfo['schoolId'];
       // echo $schoolId;
        $map['shop_id']=$schoolId;
        $map['cr.active']=1;
        $map['cr.effect']=1;
        $cookList=Db::name('Cookbook_record')->alias('cr')->join('users u','cr.append_user_id=u.id','LEFT')->limit($this->pageCount)->page($this->currentPage)->field('cr.date as theDate,cr.twitter as message,cr.files as images,u.headimgurl as avatar,u.name')->order('cr.id desc')->select();
        foreach($cookList as $key=>$value){
            $imageArray=explode(',',$value['images']);
            $cookList[$key]['images']=$value['images']?$imageArray:array();
        }

         // echo Db::getLastSql();
        $data=array('current_page'=>$this->currentPage,'cookList'=>$cookList);
        renderData(0,'ok',$data);
    }
}
